--[[/**

 * 悠依 必杀拉人buff
-- *
-- */]]

---@class BuffEffect202102 : BaseBuffEffect
BuffEffect202102 = ClientFight.CreateClass("BuffEffect202102", ClientFight.BaseBuffEffect)
local t = BuffEffect202102

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local skill =  buff.addParameters[2];
    local skillPos = skill.position;
    local targetPos = buff.target.position;
    local distance = DistanceUtil.countDistance(skillPos, targetPos);

    if (distance < 0.5) then
    return super.action(fight, buff, parameters);
    end

    -- 每次触发往中心点移动的距离a
    local move = buff.buffBean.f_BuffEffectValue[1] * 1 / 10000;
    local x = 0;
    local y = 0;
    if (distance > move) then
    --double x = skillPos.x - targetPos.x;
    --double y = skillPos.y - targetPos.y;
    --double movedx = x * move / distance;
    --double movedy = y * move / distance;
    local movedPos = MathUtil.getMovedVectorByLen(targetPos, skillPos, move);

    x = movedPos.x;
    y = movedPos.y;
    else 
    x = skillPos.x;
    y = skillPos.y;
    end
    FighterManager.changePosition(fight, buff.target, 0, x, y, 0, true, true, true);
    local logPos = targetPos;
    SkillRoleMgr.savePathFile( "[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff"
    .. buff.getModelId() .. " 往中心点移动1次(" .. getJsonStr (logPos) .. ")");
    -- 检查是否出界
   
    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
end

t.New()